import request from './request'
import { cloudUrl, baseUrl } from '@/config/config'
import store from '@/store'

// 获取店铺列表
export const storeGet = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/store/list', 'GET', params)
  })
}
// 获取店铺详情
export const storeDetailGet = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/store/getDetailById', 'GET', params)
  })
}
// 获取旗舰店详情
// export const getDetailFlagship = (params) => {
//   return new Promise((resolve, reject) => {
//     let successCallBack = function (res) {
//       if (res.data) {
//         resolve(res.data)
//       }
//     }
//     request(successCallBack, null, baseUrl + '/store/getDetailFlagship', 'GET', params)
//   })
// }
// 获取可用教练
export const coachEnabledGet = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/users/coach/listEnabled', 'GET', params)
  })
}
// 获取店铺推荐教练
export const listStoreEnabled = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/users/coach/listStoreEnabled', 'GET', params)
  })
}
// 获取教练详情
export const coachDetailGet = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/users/coach/getDetailByUserId', 'GET', params)
  })
}
// 获取单个图片
export const getPublicUrl = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/biz/annex/getPublicUrl', 'GET', params)
  })
}
// 获取图片列表
export const listPublicUrl = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/biz/annex/listPublicUrl', 'POST', params)
  })
}
// 获取店铺课程列表
export const courseGetList = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/course/storeCourseList', 'GET', params)
  })
}
// 课程详情
export const courseGetById = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/course/getById', 'GET', params)
  })
}
// 课程协议列表
export const protocolEnabledGet = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/protocol/config/listEnabled', 'GET', params)
  })
}
// 获取会员列表
export const memberPage = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/users/member/page', 'GET', params)
  })
}
// 教练创建预约
export const coachOrderAdd = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/appointment/coachAdd', 'POST', params)
  })
}
// 签约课程列表
export const signPage = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/sign/course/pageMemberUserSignCourse', 'GET', params)
  })
}
// 签约管理详情
export const signGet = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/sign/course/get', 'GET', params)
  })
}
// 获取可预约教练
export const listCoachByStoreIdAndMemberUserId = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/appointment/listCoachByStoreIdAndMemberUserId', 'GET', params)
  })
}
// 获取可预约签约课程
export const listSignCourseByTeachCoachUserIdAndMemberUserId = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/appointment/listSignCourseByTeachCoachUserIdAndMemberUserId', 'GET', params)
  })
}
// 会员创建预约
export const memberAdd = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/appointment/memberAdd', 'POST', params)
  })
}
// 获取个人信息
export const memberInfo = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/users/member/info', 'GET', params)
  })
}
// 分页获取会员已签约列表
export const pageMemberUserSignCourse = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/sign/course/pageMemberUserSignCourse', 'GET', params)
  })
}
// 预约列表
export const appointmentPage = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/appointment/page', 'POST', params)
  })
}
// 获取教练可预约会员
export const listMemberByCoachUserId = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/appointment/listMemberByCoachUserId', 'GET', params)
  })
}
// 获取系统内置字典
export const dicGet = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/dic/list', 'GET', params)
  })
}
// 获取会员列表
export const memberPageGet = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/users/member/page', 'GET', params)
  })
}
// 获取支付二维码
export const getPayQr = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/system/config/getPayQr', 'GET', params)
  })
}
// 签约管理列表
export const signAdd = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/sign/course/add', 'POST', params)
  })
}
// 分页获取教练授课的签约列表
export const pageTeachCoachUserSignCourse = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/sign/course/pageTeachCoachUserSignCourse', 'GET', params)
  })
}
// 确认支付
export const confirmPayment = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/confirmPayment', 'POST', params)
  })
}
// 获取协议详情
export const protocolGetById = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/protocol/config/getById', 'GET', params)
  })
}
// 取消预约
export const disAppointment = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/appointment/cancelAppointment', 'POST', params)
  })
}
// 会员编辑
export const memberEdit = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/users/member/edit', 'POST', params)
  })
}
// 教练编辑
export const coachEdit = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/users/coach/edit', 'POST', params)
  })
}
// 核销（id为预约id）
export const writeOffAppointment = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/appointment/writeOff', 'POST', params)
  })
}
// 会员核销（id为预约id）
export const memberWriteOff = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/appointment/memberWriteOff', 'POST', params)
  })
}
// 预约作废（id为预约id）
export const appointmentCancel = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/appointment/cancel', 'POST', params)
  })
}
// 设置教练
export const setFaceImage = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/users/coach/setFaceImage', 'POST', params)
  })
}
// 获取课程列表
export const coursePageList = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/course/pageList', 'GET', params)
  })
}
// 获取教练已预约的时间列表
export const coachBookedTime = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/appointment/coachBookedTime', 'GET', params)
  })
}
// 订单类型统计
export const signCourseTypeAndMoneyStatistic = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/statistic/signCourseTypeAndMoneyStatistic', 'POST', params)
  })
}
// 教练耗课数
export const statisticGroupByCoachUserIdAndSaleMode = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/statistic/statisticGroupByCoachUserIdAndSaleMode', 'POST', params)
  })
}
// 教练业绩
export const coachSignStatistic = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/statistic/coachSignStatistic', 'POST', params)
  })
}
// 教练耗课金额
export const coachSignCourseUsedStatistic = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/statistic/coachSignCourseUsedStatistic', 'POST', params)
  })
}
// 私教课程消耗统计
export const signCourseUsedStatistic = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/statistic/signCourseUsedStatistic', 'POST', params)
  })
}
// 教练耗课详情
export const selectCoachUsedDetail = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/statistic/selectCoachUsedDetail', 'POST', params)
  })
}
// 获取我可见的教练列表
export const coachVisibleList = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/users/coach/visibleList', 'GET', params)
  })
}
// 会员统计
export const userStatistic = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/statistic/userStatistic', 'GET', params)
  })
}
// 我的统计数据
export const statisticMy = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/statistic/statisticMy', 'POST', params)
  })
}
// 订单管理
export const orderGet = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/order/page', 'POST', params, true, {})
  })
}
// 门禁记录
export const pageAccessLog = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/device/pageAccessLog', 'POST', params)
  })
}

// 统计教练学员的耗课情况
export const statisticGroupByMemberUserIdAndSignCourseId = (params) => {
  return new Promise((resolve, reject) => {
    let successCallBack = function (res) {
      if (res.data) {
        resolve(res.data)
      }
    }
    request(successCallBack, null, baseUrl + '/statistic/statisticGroupByMemberUserIdAndSignCourseId', 'POST', params)
  })
}